package dao.impl;

import dao.BaseDao;
import dao.Order_OrderItem_Dao;
import utils.JDBCUtils;

import java.sql.Connection;
import java.sql.SQLException;

public class Order_OrderItem_DaoImpl extends BaseDao implements Order_OrderItem_Dao {
    @Override
    public Object queryUsernameByOrderId(String orderId) {
        Connection connection = null;
        Object res = null;
        try {
            //使用内连接
            String sql = "SELECT name FROM user INNER JOIN t_order ON user.id = t_order.user_id WHERE t_order.order_id = ?;";
            connection = JDBCUtils.getDruidConnection();
            res = queryForSingleValue(connection, sql, orderId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtils.closeResource(connection,null);
        }
        return res;
    }
}
